package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.WorkspaceService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
public class WorkspaceController {

    @Autowired
    private WorkspaceService workspaceService;
    /**
     * 查看菜品总览
     */
    @GetMapping("/overviewDishes")
    public Result selectDish(){
        DishOverViewVO dishOverViewVO = workspaceService.selectDish();
        return Result.success(dishOverViewVO);
    }


    /**
     * 查看套餐总览
     */
    @GetMapping("/overviewSetmeals")
    public Result selectSetmeal(){
        DishOverViewVO dishOverViewVO = workspaceService.selectSetmeal();
        return Result.success(dishOverViewVO);
    }

    /**
     * 查询订单的数据
     */
    @GetMapping("/overviewOrders")
    public Result selecOrders(){
        OrderOverViewVO orderOverViewVO = workspaceService.selecOrders();
        return Result.success(orderOverViewVO);
    }

    /**
     * 查询今日运营数据
     */
    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData(){
        //设置当天的开始时间和结束时间
        LocalDateTime todayStart = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
        LocalDateTime todayEnd = LocalDateTime.of(LocalDate.now(), LocalTime.MAX);
        BusinessDataVO businessDataVO = workspaceService.businessData(todayStart,todayEnd);
        return Result.success(businessDataVO);
    }
}
